﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using PublicCommon;
using T_Person.Domain;
using T_Person.Read.APi.Applaction.Command;
using T_Person.Read.APi.Applaction.Command.Employment;
using T_Person.Read.APi.Applaction.Command.TotalPersonnel;
using T_Person.Read.APi.Dto;

namespace T_Person.Read.APi.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class EmployeeReadApIController : ControllerBase
    {
        private readonly IMediator mediator;

        public EmployeeReadApIController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 获取员工的分页显示
        /// </summary>
        /// <param name="employeeSearchCommand"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<PageResult<EmployeeDto>> GetEmployeePageResult([FromQuery] EmployeeSearchCommand employeeSearchCommand)
        {
            return await mediator.Send(employeeSearchCommand);
        }
        /// <summary>
        /// 获取员工名称和id下拉列表
        /// </summary>
        /// <param name="employSearchByStateCommand"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<EmployeeNameDto>> GetEmployeeNameDtos([FromQuery] EmploySearchByStateCommand employSearchByStateCommand)
        {

            return await mediator.Send(employSearchByStateCommand);
        }
        /// <summary>
        /// 通过部门id获取相关人员下拉列表
        /// </summary>
        /// <param name="employeeSearchByDidCommand"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<EmployeeNameDto>> GetEmployeeNameDtosByDid([FromQuery] EmployeeSearchByDidCommand employeeSearchByDidCommand)
        {
            return await mediator.Send(employeeSearchByDidCommand);
        }
        /// <summary>
        /// 反填数据
        /// </summary>
        /// <param name="employeeSearchByidCommand"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Employee> GetEmployeeByid([FromQuery]EmployeeSearchByidCommand employeeSearchByidCommand)
        {
            return await mediator.Send(employeeSearchByidCommand);
        }
        /// <summary>
        /// 通过所属部门和员工状态查询员工姓名和主键
        /// </summary>
        /// <param name="employeeSearchByDidandState"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<PublicArray>> GetEmployeeArrayByDidandState([FromQuery]EmployeeSearchByDidandState employeeSearchByDidandState)
        {
            return await mediator.Send(employeeSearchByDidandState);
        }
        /// <summary>
        /// 获取电话号码
        /// </summary>
        /// <param name="employeeSearchByname"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<PulicArrayOperator> GetEmployeeByname([FromQuery] EmployeeSearchBynamesCommand employeeSearchByname)
        {
            return await mediator.Send(employeeSearchByname);
        }
        /// <summary>
        /// 上级负责人
        /// </summary>
        /// <param name="employeeSearchByNameandStatewords"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<PublicArray>> GetEmployeeBynamewords([FromQuery]EmployeeSearchByNameandStatewords employeeSearchByNameandStatewords)
        {
            return await mediator.Send(employeeSearchByNameandStatewords);
        }
        /// <summary>
        /// 获取年龄区间
        /// </summary>
        /// <param name="totalAgeEmployeeCommand"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<PersonnelAgeGroup>> GetAgeGroups([FromQuery]TotalAgeEmployeeCommand totalAgeEmployeeCommand)
        {
            return await mediator.Send(totalAgeEmployeeCommand);
        }
        /// <summary>
        /// 获取工龄
        /// </summary>
        /// <param name="totalPersonnelSeniorityCommand"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<PersonnelAgeGroup>> GetSeniorGroups([FromQuery]TotalPersonnelSeniorityCommand totalPersonnelSeniorityCommand)
        {
            return await mediator.Send(totalPersonnelSeniorityCommand);
        }
        /// <summary>
        /// 获取部门在职人数
        /// </summary>
        /// <param name="totalPersonnelBydepartmentCommand"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<PersonnelAgeGroup>> GetDnameGroup([FromQuery]TotalPersonnelBydepartmentCommand totalPersonnelBydepartmentCommand)
        {
            return await mediator.Send(totalPersonnelBydepartmentCommand);
        }
        /// <summary>
        /// 获取每月离职人数
        /// </summary>
        /// <param name="totalPersonCountByMonthCommand"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<PersonnelAgeGroup>> GetMonthGroup([FromQuery]TotalPersonCountByMonthCommand totalPersonCountByMonthCommand)
        {
            return await mediator.Send(totalPersonCountByMonthCommand);
        }
    }
}
